import java.util.LinkedList;
import java.util.Queue;

public class TestDemo {

    public static void main1(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        TreeNode root = binaryTree.createTree();
        System.out.print("前序遍历：");
        binaryTree.preOrder(root);//A B D E H C F G
        System.out.println();
        System.out.print("中序遍历：");
        binaryTree.inOrder(root);//D B E H A F C G
        System.out.println();
        System.out.print("后序遍历：");
        binaryTree.postOrder(root);//D H E B F G C A
        System.out.println();
//        节点个数
        System.out.println(binaryTree.size(root));//8
        System.out.println(binaryTree.size2(root));//8
        System.out.println(binaryTree.size3(root));//8
//        叶子节点个数
        binaryTree.getLeafNodeCount(root);
        System.out.println(binaryTree.leftCount);//4
        System.out.println(binaryTree.getLeafNodeCount2(root));//4
//        第k层 节点个数
        System.out.println(binaryTree.getKLevelNodeCount(root, 3));//4
        System.out.println(binaryTree.getKLevelNodeCount(root, 4));//1
//        二叉树的高度
        System.out.println(binaryTree.getHeight(root));//4
        System.out.println(binaryTree.getHeight2(root));//4

//        检测值为value的元素是否存在
//        System.out.println(binaryTree.find(root,'S').val);//NullPointerException
//                  这里没有处理空指针情况
//        所以可以这样改
        try {
            TreeNode ret = binaryTree.find(root,'S');//没有该节点
//            TreeNode ret = binaryTree.find(root,'A');//65
            System.out.println(ret.val);
        }catch (NullPointerException e) {
//            e.printStackTrace();//熟悉的报红
            System.out.println("没有该节点");
        }
    }


    public static void main2(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        TreeNode root = binaryTree.createTree();
        System.out.println(binaryTree.isCompleteTree(root));//false
    }

    public static void main(String[] args) {
        Queue<TreeNode> queue = new LinkedList<>();
        queue.offer(null);
        queue.offer(null);
        queue.offer(null);
        queue.offer(null);
        System.out.println(queue.size());//4
    }





}

